const axisLabelColor="#3ad7ee";

const dataLength=100;

function fontSize(res){
    let docEl = document.documentElement,
        clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = 100 * (clientWidth / 493);
    return res*fontSize;
}

function initSocket(myChart, socketUrl, callback) {
    // myChart.showLoading();
    myChart.hideLoading(); //隐藏加载动画
    var websocket = null;
    if ('WebSocket' in window) {
        websocket = new WebSocket(socketUrl);
        console.log(websocket)
    } else {
        alert('Not support websocket')
    }
    websocket.onerror = function () {
        console.log("error")
    };
    websocket.onopen = function (event) {
        console.log("open")
    }
    websocket.onclose = function () {
        websocket.close();
    }
    window.onbeforeunload = function () {
        websocket.close();
    }
    websocket.onmessage = function (event) {
        if (typeof callback === 'function') {
            callback(event, myChart)
        }
    }

    return websocket;
}
